class MinStack {
public:
    MinStack() {

    }

    void push(int val) {
        _st.push(val);
        if (_minSt.empty() || val <= _minSt.top())
        {
            _minSt.push(val);
        }
    }

    void pop() {
        if (_st.top() == _minSt.top())
        {
            _minSt.pop();
        }
        _st.pop();
    }

    int top() {
        return _st.top();
    }

    int getMin() {
        return _minSt.top();
    }
private:
    stack<int> _st;
    stack<int> _minSt;
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */

class Solution {
public:
    int missingNumber(vector<int>& nums) {
        int ret = 0;
        for (int i = 0; i < nums.size(); i++) ret ^= nums[i];
        for (int i = 0; i <= nums.size(); i++) ret ^= i;
        return ret;
    }
};